#include "serialcamera.h"

using namespace std;

SerialCamera::SerialCamera() : Camera(){}

SerialCamera::SerialCamera( Scene *scn, Trajectory *traj, Orientation *ornt, const Vector &u, int filmW, int filmH, double fovy ) : Camera(scn,traj,ornt,u,filmW,filmH,fovy){}

void SerialCamera::render( Frame& f )
{
    int w = f.w();
    int h = f.h();
    double t = f.t();

    #pragma mta serial
    for( int ij=0; ij<w*h; ij++ )
    {
        int i = ij / w;
        int j = ij % h;
        Ray r = spawnRay( i, j, t );
        Color c = _scn->trace( r );
        f.setPixel( i, j, c );
    }
}

void SerialCamera::videoRender()
{
    int w = frames[0].w();
    int h = frames[0].h();

    #pragma mta serial
    for( int kij = 0; kij < frameCt * h * w; kij ++ )
    {
        int k   = kij / (w * h);
        int Tij = kij % (w * h);
        int i   = Tij / w;
        int j   = Tij % w;
    
        Ray r = spawnRay( i, j, frames[k].t() );
        Color c = _scn->trace( r );
        frames[k].setPixel( i, j, c );
    }
}
